<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  
  <title>Python4ever</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="人生苦短，我用python">
<meta property="og:type" content="website">
<meta property="og:title" content="Python4ever">
<meta property="og:url" content="https://py4ever.github.io/index.html">
<meta property="og:site_name" content="Python4ever">
<meta property="og:description" content="人生苦短，我用python">
<meta property="og:locale" content="en_US">
<meta property="article:author" content="雷学委&#x2F;&#x2F;">
<meta name="twitter:card" content="summary">
  
    <link rel="alternate" href="/atom.xml" title="Python4ever" type="application/atom+xml">
  
  
    <link rel="shortcut icon" href="/favicon.png">
  
  
    
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/typeface-source-code-pro@0.0.71/index.min.css">

  
  
<link rel="stylesheet" href="/css/style.css">

  
    
<link rel="stylesheet" href="/fancybox/jquery.fancybox.min.css">

  
<meta name="generator" content="Hexo 5.4.0"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">Python4ever</a>
      </h1>
      
        <h2 id="subtitle-wrap">
          <a href="/" id="subtitle">py4ever</a>
        </h2>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="https://py4ever.github.io"></form>
      </div>
    </div>
  </div>
</header>

      <div class="outer">
        <section id="main">
  
    <article id="post-py4ever主站正式发布" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
  <div class="article-meta">
    <a href="/2021/09/27/py4ever%E4%B8%BB%E7%AB%99%E6%AD%A3%E5%BC%8F%E5%8F%91%E5%B8%83/" class="article-date">
  <time class="dt-published" datetime="2021-09-27T00:52:18.000Z" itemprop="datePublished">2021-09-27</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="p-name article-title" href="/2021/09/27/py4ever%E4%B8%BB%E7%AB%99%E6%AD%A3%E5%BC%8F%E5%8F%91%E5%B8%83/">py4ever主站正式发布!</a>
    </h1>
  

      </header>
    
    <div class="e-content article-entry" itemprop="articleBody">
      
        <h1 id="py4ever"><a href="#py4ever" class="headerlink" title="py4ever"></a>py4ever</h1><p>抱着对编程的热情❤️  ， 我们聚集在这里。</p>
<p>开发一写编程的库，</p>
<p>分享编程的知识，</p>
<p>我们也建立了QQ交流群。</p>
<p>期待未来有你，加入python开发阵营；</p>
<p>期待未来有你，陪伴一起技术成长；</p>
<p>期待未来有你，一起为技术社区作出贡献。</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="https://py4ever.github.io/2021/09/27/py4ever%E4%B8%BB%E7%AB%99%E6%AD%A3%E5%BC%8F%E5%8F%91%E5%B8%83/" data-id="cku1gtkj1000k9hnkccrq3q59" data-title="py4ever主站正式发布!" class="article-share-link">Share</a>
      
      
      
    </footer>
  </div>
  
</article>



  
    <article id="post-hello-world" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
  <div class="article-meta">
    <a href="/2021/09/26/hello-world/" class="article-date">
  <time class="dt-published" datetime="2021-09-26T16:57:46.963Z" itemprop="datePublished">2021-09-26</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="p-name article-title" href="/2021/09/26/hello-world/">Hello World</a>
    </h1>
  

      </header>
    
    <div class="e-content article-entry" itemprop="articleBody">
      
        <p>Welcome to <a target="_blank" rel="noopener" href="https://hexo.io/">Hexo</a>! This is your very first post. Check <a target="_blank" rel="noopener" href="https://hexo.io/docs/">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a target="_blank" rel="noopener" href="https://hexo.io/docs/troubleshooting.html">troubleshooting</a> or you can ask me on <a target="_blank" rel="noopener" href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo new <span class="string">&quot;My New Post&quot;</span></span><br></pre></td></tr></table></figure>

<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>

<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>

<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>

<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>

      
    </div>
    <footer class="article-footer">
      <a data-url="https://py4ever.github.io/2021/09/26/hello-world/" data-id="cku1gtkiz000i9hnk5o4m175r" data-title="Hello World" class="article-share-link">Share</a>
      
      
      
    </footer>
  </div>
  
</article>



  
    <article id="post-2016-01-02-Notes-On-Creating-A-Hexo-Theme" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
  <div class="article-meta">
    <a href="/2016/01/02/2016-01-02-Notes-On-Creating-A-Hexo-Theme/" class="article-date">
  <time class="dt-published" datetime="2016-01-02T00:00:00.000Z" itemprop="datePublished">2016-01-02</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/Hexo/">Hexo</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="p-name article-title" href="/2016/01/02/2016-01-02-Notes-On-Creating-A-Hexo-Theme/">Notes On Creating A Hexo Theme</a>
    </h1>
  

      </header>
    
    <div class="e-content article-entry" itemprop="articleBody">
      
        <div class="image-strip">
<img src="https://s3.amazonaws.com/ptsteadman-images/hexo.png" class="">
</div>

<h2 id="Setup"><a href="#Setup" class="headerlink" title="Setup"></a>Setup</h2><p>To Update NPM: <code>npm install npm@latest -g</code>.</p>
<p>In 2015 it makes sense to use NVM.  <a target="_blank" rel="noopener" href="http://linoxide.com/ubuntu-how-to/install-node-js-ubuntu">NVM Installation<br>Instructions</a>.</p>
<p>Update NPM: <code>npm install npm@latest -g</code></p>
<p>Hexo: why can’t you use helper functions in source code?<br>This should be in docs.</p>
<h2 id="Creating-a-Custom-Index-File-in-Hexo"><a href="#Creating-a-Custom-Index-File-in-Hexo" class="headerlink" title="Creating a Custom Index File in Hexo"></a>Creating a Custom Index File in Hexo</h2><p>Trying to generate a custom index file in source, hexo would ignore<br><code>source/index.md</code> no matter what I did.  What I had to do was uninstall<br><code>hexo-generator-index</code>.  <a target="_blank" rel="noopener" href="https://github.com/hexojs/hexo/issues/1077">See<br>here</a>.  Then it works.  So, that<br>will be part of the setup for my theme.  But, it’s worth it in order to properly<br>seperate the theme from the content, I think.  Having everyone edit the theme<br>index.ejs template is no good.</p>
<h2 id="Hexo-Rendering-Raw-EJS-File-Problem-I-Encountered"><a href="#Hexo-Rendering-Raw-EJS-File-Problem-I-Encountered" class="headerlink" title="Hexo Rendering Raw EJS File Problem I Encountered"></a>Hexo Rendering Raw EJS File Problem I Encountered</h2><p>Sometimes the server would keep rendering an old version of my code, but as<br>text.  So I’d see stuff like</p>
<pre><code>&lt;% if (site.tags.length)&#123; %&gt;
</code></pre>
<p>The raw ejs, essentially.  Restarting the server or running <code>hexo clean</code> didn’t<br>do anything.</p>
<p>After some time, I realized it was due to the gedit swap files being read by<br>hexo as the actual layout files: for example, <code>tag.ejs~</code>.  My <code>partial</code> helpers<br>looked like: <code>&lt;%- partial(&#39;_partials/tag&#39;) %&gt;</code>, and apparently hexo was reading<br>in <code>tag.ejs~</code> instead of <code>tag.ejs</code>.  And therefore, the ejs wasn’t rendering.</p>
<p>To fix this, I simply changed my partial helper to <code>&lt;%- partial(&#39;_partials/tag.ejs&#39;) %&gt;</code>.  Problem solved.</p>
<h2 id="Hexo-Excerpt-Variable"><a href="#Hexo-Excerpt-Variable" class="headerlink" title="Hexo Excerpt Variable"></a>Hexo Excerpt Variable</h2><p>I was confused by the behavior of the hexo <code>excerpt</code> variable.  If you define<br><code>excerpt: something</code> in the front matter, hexo ignores that.  Instead, to get it<br>to work, one needs to add a <code>&lt;!-- more --&gt;</code> comment in the source of the post.<br>Or, you can install a plugin that allows you to define custom excerpt in the<br>front matter.</p>
<h2 id="Scripts-Directory"><a href="#Scripts-Directory" class="headerlink" title="Scripts Directory"></a>Scripts Directory</h2><p>One of the things I really discovered too late is the “Scripts” directory in the<br>theme folder.  In Hexo, the various plugins drive the structure of the site, as<br>opposed to the placement of different files and directories, as in Jekyll.  The<br>plugins programatically create folder structure, etc, where in Jekyll I mostly<br>used the liquid markup to structure the site.  </p>
<p>The problem is, then, that the user wants to extend hexo to do some sort of<br>custom thing.  If one had to publish a new plugin, that’d be too much work.  But<br>the theme level scripts folder allows one to extend the base hexo functionality<br>in ‘user space’ effectively.</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="https://py4ever.github.io/2016/01/02/2016-01-02-Notes-On-Creating-A-Hexo-Theme/" data-id="cku1gtkix000e9hnk60xgcyoy" data-title="Notes On Creating A Hexo Theme" class="article-share-link">Share</a>
      
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Design/" rel="tag">Design</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Programming/" rel="tag">Programming</a></li></ul>

    </footer>
  </div>
  
</article>



  
    <article id="post-2015-05-02-How-To-Impress" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
  <div class="article-meta">
    <a href="/2015/05/02/2015-05-02-How-To-Impress/" class="article-date">
  <time class="dt-published" datetime="2015-05-02T00:00:00.000Z" itemprop="datePublished">2015-05-02</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/Humor/">Humor</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="p-name article-title" href="/2015/05/02/2015-05-02-How-To-Impress/">How To Impress Employers at Infosessions</a>
    </h1>
  

      </header>
    
    <div class="e-content article-entry" itemprop="articleBody">
      
        <p>Top tech talent knows that industry recruiters often bring a stack of<br>pre-negotiated offers to university infosessions, so that they can snag<br>programmers and UX designers who really stand out.  Instead of spending valuable<br>time validating a particularly promising candidate’s skillset through a<br>protracted series of interviews, it’s often more efficient to simply <strong>give the<br>individual an offer right then and there</strong>.  Internal studies at Google have shown<br>that experienced recruiters can usually tell if a programmer has ‘what it takes’<br>just from how they act at infosessions: the insightful questions they ask, the<br>stickers on their laptop, and how they comport themselves in general.</p>
        
          <p class="article-more-link">
            <a href="/2015/05/02/2015-05-02-How-To-Impress/#more">Read More</a>
          </p>
        
      
    </div>
    <footer class="article-footer">
      <a data-url="https://py4ever.github.io/2015/05/02/2015-05-02-How-To-Impress/" data-id="cku1gtkiw000d9hnk3sn402fg" data-title="How To Impress Employers at Infosessions" class="article-share-link">Share</a>
      
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/employment/" rel="tag">employment</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/funny/" rel="tag">funny</a></li></ul>

    </footer>
  </div>
  
</article>



  
    <article id="post-2015-04-08-NAV-Programming-Resources" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
  <div class="article-meta">
    <a href="/2015/04/08/2015-04-08-NAV-Programming-Resources/" class="article-date">
  <time class="dt-published" datetime="2015-04-08T00:00:00.000Z" itemprop="datePublished">2015-04-08</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/Dynamics-NAV/">Dynamics NAV</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="p-name article-title" href="/2015/04/08/2015-04-08-NAV-Programming-Resources/">NAV Web Service Programming Resources</a>
    </h1>
  

      </header>
    
    <div class="e-content article-entry" itemprop="articleBody">
      
        <p>Here are some of the resources I found helpful for learning to develop Dynamics NAV web service based applications.</p>
<h4 id="C-AL-Programming"><a href="#C-AL-Programming" class="headerlink" title="C/AL Programming:"></a>C/AL Programming:</h4><p><a target="_blank" rel="noopener" href="http://www.consultec.es/DocTutoriales/Introduction_to_CAL_Programming.pdf">Introduction to CAL Programming</a><br>This provides a good overview of the basics of CAL programming, which can become necessary in building a web service applications when a custom codeunit or page extension is required.</p>
<h4 id="Setting-up-Web-Services"><a href="#Setting-up-Web-Services" class="headerlink" title="Setting up Web Services:"></a>Setting up Web Services:</h4><p><a target="_blank" rel="noopener" href="http://vjeko.com/blog/connecting-to-nav-through-web-services-recorded-session">Vjecko Web Service Recorded Session</a><br>Vjecko.com has a lot of detailed articles about web service programming, but this older post has a pdf and recorded session that shows how to expose and connect to web services from a .NET application.  Unfortunately, he shows how to create Web Service references in .NET using the now-deprecated Web Refrence method (from .NET 2) instead of the more current Service Reference method.</p>
<p><a target="_blank" rel="noopener" href="http://blogs.msdn.com/b/freddyk/archive/2010/01/20/connecting-to-nav-web-services-from-c-using-service-reference-config-file-version.aspx">Using Service Reference to Connect to Web Services</a><br>This explains how to use Service Reference, using code instead of XML web.config configuration, which I found difficult to configure.  (Each time I updated the service reference, I would have to reconfigure the XML).</p>
<h4 id="NAV-Upgrade-Process"><a href="#NAV-Upgrade-Process" class="headerlink" title="NAV Upgrade Process:"></a>NAV Upgrade Process:</h4><p><a target="_blank" rel="noopener" href="http://saurav-nav.blogspot.com/2012/12/nav-2013-upgrade-part-iv-sql-migration.html">Migration to SQL Server from C/SIDE Database</a><br>In order to use web services, you don’t need to be using the Role Tailored Client, but you must be using the a SQL server based NAV database.  Web Services can be configured and exposed using the Classic Client for SQL Server Databases.</p>
<p><a target="_blank" rel="noopener" href="http://blogs.msdn.com/b/nav/archive/2012/03/05/rtc-debugging.aspx">Debugging Code Called by Web Services</a><br>C/AL code won’t necessarily execute the same as it did in the Classic Client when called  as a Web Service.  C/AL code called as web service execute in the NAV Server tier, instead of the client.  <a target="_blank" rel="noopener" href="http://msdn.microsoft.com/en-us/library/ff477107.aspx">Certain functions</a> aren’t available for code running in the NAV Server, and some design changes need to be made (for example, CONFIRM dialogue boxes don’t make sense in the context of a web service).  To debug the codeunits called through web services (or the Role Tailored Client), you will need to use Visual Studio.<br><a target="_blank" rel="noopener" href="http://msdn.microsoft.com/en-us/library/dd338765.aspx#SU">More information.</a></p>
<h4 id="Deploying-a-NET-Application"><a href="#Deploying-a-NET-Application" class="headerlink" title="Deploying a .NET Application:"></a>Deploying a .NET Application:</h4><p><a target="_blank" rel="noopener" href="http://www.asp.net/mvc/overview/deployment/visual-studio-web-deployment/deploying-to-iis">Deploying to IIS</a>  After you’ve built a .NET application that consumes .NET web services, you’ll have to find a way to deploy it on your servers, or Azure.  Connection strings can be used to specify different NAV servers for different environments (like development, QA, and prod).</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="https://py4ever.github.io/2015/04/08/2015-04-08-NAV-Programming-Resources/" data-id="cku1gtkiu000a9hnkcmd16knh" data-title="NAV Web Service Programming Resources" class="article-share-link">Share</a>
      
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/NAV/" rel="tag">NAV</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Resources/" rel="tag">Resources</a></li></ul>

    </footer>
  </div>
  
</article>



  
    <article id="post-2015-04-05-Lookup-on-Page" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
  <div class="article-meta">
    <a href="/2015/04/05/2015-04-05-Lookup-on-Page/" class="article-date">
  <time class="dt-published" datetime="2015-04-05T00:00:00.000Z" itemprop="datePublished">2015-04-05</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/Dynamics-NAV/">Dynamics NAV</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="p-name article-title" href="/2015/04/05/2015-04-05-Lookup-on-Page/">Adding Lookup Field to a Page in Dynamics NAV</a>
    </h1>
  

      </header>
    
    <div class="e-content article-entry" itemprop="articleBody">
      
        <p>One of the problems I faced in building a non-trivial application that consumed<br>NAV Web Services was figuring out how to “join” fields from different tables.<br>For example, when exposing a list of jobs from a job table which includes a<br>resource needed for the job, you might need more than just the resource id<br>that’s a field in the table: you might also need the resource name and<br>description.  While this is easy to get for one record, what about when you<br>need a few hundred records in a table that has been dynamically filtered?  When<br>exposing a Page as a web service, it’s easy to include the fields of the table<br>that the page is based on, but it’s less clear how to include fields from<br>another table.</p>
<p>Forum posts like <a target="_blank" rel="noopener" href="http://dynamicsuser.net/forums/p/32550/170843.aspx">this</a> led me to believe that I couldn’t expose flow fields in a Page web service, and I would get exceptions when I tried to expose all the fields of a table.  In fact, it’s perfectly possible to expose a flow field: it’s <strong>flow filters</strong> that don’t work with web services.  But, I also didn’t want to modify the underlying [job] table to add a flow field, and didn’t see an easy way of adding a flow field to a Page.  I tried “joining” the data in the C# application, but found network overhead made the application unusuably slow.</p>
<p>The solution to this problem was to use C/AL code to the Page to effectively create a lookup / flow field.  This way, the data is “pre-joined” before leaving the NAV Server, which is fast and clean, but you didn’t modify any tables.  Here’s how it’s done:</p>
<p>Step 1. <strong>Add a Field with SourceExpression Set to a Function Name</strong></p>
<p>To start, we create a Page using the wizard that includes all of the fields of an underlying table.  Then, we create manually add fields that will contain the lookup data from other tables.  The text in the SourceExpression column will be the name of the function that populates this field.<br><img src="http://ptsteadman.github.io/images/lookup-1.PNG" alt="Add a Field with SourceExpression Set to a Function Name"></p>
<p>Step 2. <strong>Create Function in the Page’s C/AL Code</strong></p>
<p>With the Page field designer open, go to the functions tab of C/AL Globals form, and add a function with the name of the text in the SourceExpression column.  Set the return type of the function with the “Locals” button, and a function trigger will appear in the C/AL code editor for your page.  Add code to the body of the function trigger that will be called for each record to provide a value for the field.<br><img src="http://ptsteadman.github.io/images/lookup-2.PNG" alt="Create Function in the Page&#39;s C/AL Code"></p>

      
    </div>
    <footer class="article-footer">
      <a data-url="https://py4ever.github.io/2015/04/05/2015-04-05-Lookup-on-Page/" data-id="cku1gtkit00099hnk24p7a0a5" data-title="Adding Lookup Field to a Page in Dynamics NAV" class="article-share-link">Share</a>
      
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/NAV/" rel="tag">NAV</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Resources/" rel="tag">Resources</a></li></ul>

    </footer>
  </div>
  
</article>



  
    <article id="post-2015-04-01-NGINX-Static-Locations" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
  <div class="article-meta">
    <a href="/2015/04/01/2015-04-01-NGINX-Static-Locations/" class="article-date">
  <time class="dt-published" datetime="2015-04-01T00:00:00.000Z" itemprop="datePublished">2015-04-01</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/NGINX/">NGINX</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="p-name article-title" href="/2015/04/01/2015-04-01-NGINX-Static-Locations/">Static NGINX Locations</a>
    </h1>
  

      </header>
    
    <div class="e-content article-entry" itemprop="articleBody">
      
        <p>I try to get a lot of mileage out of the single AWS t2.micro instance I keep running,<br>which means I have many different projects running on different paths on a single server.  Everytime I finish a project, I have to relearn how to add new “locations” (paths) to the NGINX virtual host.</p>
<p>I was really frustrated when I couldn’t figure out how to add a static location for the Jekyll<br>website I created for the game I’m developing.  I kept trying to do something like this:</p>
<pre><code>location / &#123;
  root /home/ubuntu/personal-website;
&#125;
location /array &#123;
  root /home/ubuntu/array-website/_site;
&#125;
</code></pre>
<p>But everytime I tried to visit [<a target="_blank" rel="noopener" href="http://ptsteadman.com/array]">http://ptsteadman.com/array]</a>, I would get a 404 error.<br>I tried a bunch of things: I changed the “root” of the the <code>/</code> location to my game website, and it worked.  But no matter what I did, after using <code>sudo service nginx restart</code>,<br>trying to visit the <code>/array</code> location still resulted in a 404.  I couldn’t add the new route/location.</p>
<p>Eventually, I realized that the text after the slash in the location is the directory that<br>NGINX will try to find in the “root” location.  So, <code>location /array</code> will look for the directory (or file)<br><code>array</code> in whatever directory “root” is set to.  So, I created a symlink to the root of my<br>static jekyll site with the command <code>ln -s /home/ubuntu/array-website/_site /home/ubuntu/array</code>, and<br>then I could set up my nginx config file in <code>sites-enabled</code> as below:</p>
<pre><code>location / &#123;
  root /home/ubuntu/personal-website;
&#125;
location /array &#123;
  root /home/ubuntu;
&#125;
</code></pre>
<p>I think this stuff is all pretty obvious to someone who really understands NGINX and file serving,<br>but I only touch NGINX when I’ve finished a project and feel impatient to deploy.  I think it’s very confusing<br>that NGINX seems to handle paths differently between <code>/</code> locations and and <code>/foo</code> locations,<br>but a real understanding of NGINX might clear things up.</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="https://py4ever.github.io/2015/04/01/2015-04-01-NGINX-Static-Locations/" data-id="cku1gtkir00079hnkdslr5nio" data-title="Static NGINX Locations" class="article-share-link">Share</a>
      
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Web-Development/" rel="tag">Web Development</a></li></ul>

    </footer>
  </div>
  
</article>



  
    <article id="post-2015-03-23-Make-VS-Insert-Spaces" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
  <div class="article-meta">
    <a href="/2015/03/23/2015-03-23-Make-VS-Insert-Spaces/" class="article-date">
  <time class="dt-published" datetime="2015-03-23T00:00:00.000Z" itemprop="datePublished">2015-03-23</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/NET/">.NET</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="p-name article-title" href="/2015/03/23/2015-03-23-Make-VS-Insert-Spaces/">Spaces for Newline Indents in VS</a>
    </h1>
  

      </header>
    
    <div class="e-content article-entry" itemprop="articleBody">
      
        <p>It’s really annoying when Visual Studio shows you this:</p>
<img src="http://ptsteadman.github.io/images/vs1.png" class="">


<p>But github or vim shows you the same file like this:</p>
<img src="http://ptsteadman.github.io/images/vim1.png" class="">

<p>If you use the “show whitespace” Visual Studio chord <code>(CTRL-R, CTRL-W)</code>,<br>you’ll see that visual studio inserts tabs instead of spaces by<br>default for newline indent:</p>
<img src="http://ptsteadman.github.io/images/ws.png" class="">

<p>Visual Studio displays tabs as having the same<br>width as four spaces.  But if you’re collaborating with someone working<br>in another text editor like vim, your automatically-inserted tabs will<br>appear larger than four spaces.</p>
<p>Here’s how to make visual studio insert spaces instead of tabs on newline indents:<br>go to <code>Tools-&gt;Options-&gt;Text Editor-&gt;All Languages-&gt;Tabs</code>:</p>
<img src="http://ptsteadman.github.io/images/spaces.png" class="">

<p>That’s better:</p>
<img src="http://ptsteadman.github.io/images/ws2.png" class="">

      
    </div>
    <footer class="article-footer">
      <a data-url="https://py4ever.github.io/2015/03/23/2015-03-23-Make-VS-Insert-Spaces/" data-id="cku1gtkim00039hnk5a33e61i" data-title="Spaces for Newline Indents in VS" class="article-share-link">Share</a>
      
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/C/" rel="tag">C#</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Visual-Studio/" rel="tag">Visual Studio</a></li></ul>

    </footer>
  </div>
  
</article>



  
    <article id="post-2014-02-23-hello-world" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
  <div class="article-meta">
    <a href="/2014/02/23/2014-02-23-hello-world/" class="article-date">
  <time class="dt-published" datetime="2014-02-23T00:00:00.000Z" itemprop="datePublished">2014-02-23</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/Hexo/">Hexo</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="p-name article-title" href="/2014/02/23/2014-02-23-hello-world/">Welcome To Hexo</a>
    </h1>
  

      </header>
    
    <div class="e-content article-entry" itemprop="articleBody">
      
        <p>Welcome to <a target="_blank" rel="noopener" href="http://hexo.io/">Hexo</a>! This is your very first post. Check <a target="_blank" rel="noopener" href="http://hexo.io/docs/">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a target="_blank" rel="noopener" href="http://hexo.io/docs/troubleshooting.html">troubleshooting</a> or you can ask me on <a target="_blank" rel="noopener" href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo new <span class="string">&quot;My New Post&quot;</span></span><br></pre></td></tr></table></figure>
        
          <p class="article-more-link">
            <a href="/2014/02/23/2014-02-23-hello-world/#more">Read More</a>
          </p>
        
      
    </div>
    <footer class="article-footer">
      <a data-url="https://py4ever.github.io/2014/02/23/2014-02-23-hello-world/" data-id="cku1gtkij00019hnkf29ofnz2" data-title="Welcome To Hexo" class="article-share-link">Share</a>
      
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/How-To/" rel="tag">How-To</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Welcome/" rel="tag">Welcome</a></li></ul>

    </footer>
  </div>
  
</article>



  


</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Categories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/NET/">.NET</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Dynamics-NAV/">Dynamics NAV</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Hexo/">Hexo</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Humor/">Humor</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/NGINX/">NGINX</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/C/" rel="tag">C#</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Design/" rel="tag">Design</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/How-To/" rel="tag">How-To</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/NAV/" rel="tag">NAV</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Programming/" rel="tag">Programming</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Resources/" rel="tag">Resources</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Visual-Studio/" rel="tag">Visual Studio</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Web-Development/" rel="tag">Web Development</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Welcome/" rel="tag">Welcome</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/employment/" rel="tag">employment</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/funny/" rel="tag">funny</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/tags/C/" style="font-size: 10px;">C#</a> <a href="/tags/Design/" style="font-size: 10px;">Design</a> <a href="/tags/How-To/" style="font-size: 10px;">How-To</a> <a href="/tags/NAV/" style="font-size: 20px;">NAV</a> <a href="/tags/Programming/" style="font-size: 10px;">Programming</a> <a href="/tags/Resources/" style="font-size: 20px;">Resources</a> <a href="/tags/Visual-Studio/" style="font-size: 10px;">Visual Studio</a> <a href="/tags/Web-Development/" style="font-size: 10px;">Web Development</a> <a href="/tags/Welcome/" style="font-size: 10px;">Welcome</a> <a href="/tags/employment/" style="font-size: 10px;">employment</a> <a href="/tags/funny/" style="font-size: 10px;">funny</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/09/">September 2021</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/01/">January 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/05/">May 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/04/">April 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/03/">March 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/02/">February 2014</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2021/09/27/py4ever%E4%B8%BB%E7%AB%99%E6%AD%A3%E5%BC%8F%E5%8F%91%E5%B8%83/">py4ever主站正式发布!</a>
          </li>
        
          <li>
            <a href="/2021/09/26/hello-world/">Hello World</a>
          </li>
        
          <li>
            <a href="/2016/01/02/2016-01-02-Notes-On-Creating-A-Hexo-Theme/">Notes On Creating A Hexo Theme</a>
          </li>
        
          <li>
            <a href="/2015/05/02/2015-05-02-How-To-Impress/">How To Impress Employers at Infosessions</a>
          </li>
        
          <li>
            <a href="/2015/04/08/2015-04-08-NAV-Programming-Resources/">NAV Web Service Programming Resources</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      
      &copy; 2021 雷学委//<br>
      Powered by <a href="https://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>

    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    


<script src="/js/jquery-3.4.1.min.js"></script>



  
<script src="/fancybox/jquery.fancybox.min.js"></script>




<script src="/js/script.js"></script>





  </div>
</body>
</html>